
{% extends 'authuser/base.html' %}
{% block content %}
<style type="text/css" media="screen" id="test">
	.warn{
		color: red;
	}
</style>
<script type="text/javascript">
	
		app.controller('content',function ($scope,$http,$timeout) {
			$scope.next="{{next |default:'/'}}";
			var login_url='{{login_url}}'
			$scope.is_login={{ is_login |default:'false'}}
			
			$scope.user={
				name:'',
				password:''
			}
			$scope.infome=false;
			$scope.submit_func=function (valid) {
				$scope.submit_clicked=true;
				if(!valid)return;
				if ($scope.user.password1!=$scope.user.password2){
					$scope.stdout='两次密码不一致';
					return;
					}
				var postData={
					registe:{username:$scope.user.username,password:$scope.user.password1}
				}
				$http.post('',postData)
				.success(function(data, status, headers, config) {  
					if(data.registe.status=='success'){
						location=login_url;
					}else{
						$scope.stdout=data.registe.msg;
					}
					
				}).error(function(data, status, headers, config) {  
				    //处理错误 
				    $scope.stdout='有错误,返回码为:',
				    $scope.stdout+=status; 
				});  
				
			};
			$scope.eq=function (a,b) {
			 	return (a==b)
				};
			
		});
</script>
<div class='container'>
	<div ng-controller='content'>

	<form name="regForm" 
		ng-submit='submit_func(regForm.$valid)' 
		class='form-signin' novalidate>
		<h2 class='form-signin-heading'>用户注册</h2>
		<div class="form-group" style='margin-top:30px;'>
		    <label for="usrname">*用户名:</label>
		    <input type="text" class='form-control' 
		    		name='usrname' placeholder='username' 
		    		ng-model='user.username' required autofocus>
			<p ng-show='regForm.usrname.$error.required&&submit_clicked' 
				class='warn'>用户名不能为空</p>
		</div>
		
		
		<div class="form-group">
		  <label for="pswd1">第一次输入密码</label>
		  <input type="password" 
		  		class='form-control' 
		  		name="pswd1" 
		  		placeholder='password' 
		  		ng-model='user.password1' required />
		  <p ng-show='regForm.pswd1.$error.required&&submit_clicked'
		  		class='warn'>密码不能为空</p>
		</div>

		
		<div class="form-group">
			<label for="pswd2">第二次输入密码</label>
			<input type="password" 
				class='form-control' 
				name="pswd2" 
				placeholder='password' 
				ng-model='user.password2' required />
			<p ng-show='user.password1!=user.password2&&submit_clicked' 
				class='warn'>
				两次密码不相等
			</p>
		</div>
		<input type="submit" class='btn btn-lg btn-primary btn-block' value="注册" />
		
	</form>

	<!--<div id='stdout' ng-bind='stdout' class='form-signin' style='color:red'></div>-->
	<div auto-hide data='stdout' class='form-signin' style='color:red'></div>
</div>

</div>
<style type="text/css">
	.form-signin{
		max-width:330px;
		padding: 15px;
		margin: 0 auto;
	}
	input{
		margin-bottom:3px;
	}
</style>

{% endblock %}